package org.meetunexpectedly.entity.vo;

import lombok.Data;
import org.meetunexpectedly.holder.UserHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 用户模型
 * @Author: pupil
 * @Date: 2024/08/23 下午 2:30
 */
@Data
public class UserModel {
    // 视频模型集合
    private List<Model> models;
    // 用户ID
    private Long userId;

    /**
     * 创建用户模型
     * @param labels 标签
     * @param videoId 视频id
     * @param probability 概率
     * @return
     */
    public static UserModel buildUserModel(List<String> labels, Long videoId, Double probability) {
        UserModel userModel = new UserModel();
        ArrayList<Model> models = new ArrayList<>();
        userModel.setUserId(UserHolder.get());
        for (String label : labels) {
            Model model = new Model();
            model.setLabel(label);
            model.setVideoId(videoId);
            model.setScore(probability);
            models.add(model);
        }
        userModel.setModels(models);
        return userModel;
    }
}
